function myDisplayAllfunction()
    record = {}
    b = 0
    count = 1
    for line in io.lines("data.txt") do 
        record[b] = line
        b = b + 1
    end
    for i = 1, table.maxn(record) do
        print(record[i])
        if count == 4 then
            print("\n")
            count = 0
        end
        count = count + 1
        i = i + 1
    end
    print("\nPress enter to continue......")
    wait = io.read()
end

function myAddfunction()
    file = io.open("data.txt", "a")
    io.output(file)
    print("Please enter the category: ")
    answer = io.read()
    io.write("\nCategory = " .. answer)
    print("\nPlease enter a description of the expense: ")
    answer = io.read()
    io.write("\nDescription = " .. answer)
    print("\nPlease enter date: ")
    answer = io.read()
    io.write("\nDate = " .. answer)
    print("\nPlease enter cost of expense: ")
    answer = io.read()
    io.write("\nCost = " .. answer)
    io.close(file)
    print("\nYour entry has been recorded.....")
    print("\nPress enter to continue.....")
    wait = io.read()
end

function expenseTotal()
    record = {}
    count = 0
    b = 0
    total = 0
    for line in io.lines("data.txt") do 
        record[b] = line
        if count == 4 then
            num = string.match(record[b], "%d+%.%d+")
            count = 0
            total = total + num
        end
    b = b + 1
    count = count + 1
    end
    print("\nNumber of expenses = " .. (table.maxn(record) / 4))
    print("Total cost = $" .. total .. "\n")
    print("\nPress enter to continue......")
    wait = io.read()
end

function myErasefunction()
    print("\nAre you sure you want to delete all entries? y / n? ")
    sure = io.read()
    if sure == "y" or sure == "Y" then
        file = io.open("data.txt", "w")
        io.output(file)
        print("\nAll entries have been erased.....")
        file:write()
        io.close(file)
    else
        print("Action canceled....")
    end
    print("\nPress enter to continue.....")
    wait = io.read()
end